import { Dispatch } from 'redux';
import { setLoading } from './app';

const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));

export enum ActionType {
    ADD_NUM = 'ADD_NUM',
}

export const addNumAsync = () => async (dispatch: Dispatch) => {
    dispatch(setLoading(true));
    await delay(1000);
    dispatch(setLoading(false));
    dispatch({
        type: ActionType.ADD_NUM,
    });
};
